<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>农产品质量安全追溯系统 - ${typeName }</title>
<link rel="stylesheet" href="${path }/cms/css/public.css"/>
<link rel="stylesheet" href="${path }/cms/css/qualityMeasures.css"/>
<script type="text/javascript" src="${path }/cms/js/jquery-1.8.3.min.js"></script>
</head>
<body>
<div class="qualityMeasures">
    <%@ include file="/WEB-INF/cms/header.jsp" %>

    <div class="contentBox">
        <div class="contentTitle">
           ${typeName }
        </div>

        <div class="bImgTextBox" id="newslist">
        </div>

        <div class="pageBox">
		    <div class="counter" id="pageCounter"></div>
		    <button class="paginate left" id="pagePrev"><i></i><i></i></button>
		    <button class="paginate right" id="pageNext"><i></i><i></i></button>
		</div>

    </div>
    <%@ include file="/WEB-INF/cms/footer.jsp" %>

</div>
<script type="text/javascript" src="${path }/res/js/myutils.js"></script>
<script type="text/javascript">
var imgpath = '${filepath}/news_img/';
var pagePrev, pageNext, pageCounter, pageNo=1, pageCount=10000;
$(function(){
	pagePrev = $('#pagePrev');
	pagePrev.click(function(){
		if(pageNo<=1){
			pageNo = 1;
		}else{
			pageNo--;
		}
		loadPage(pageNo);
	});
	pageNext = $('#pageNext');
	pageNext.click(function(){
		if(pageNo>=pageCount){
			pageNo = pageCount;
		}else{
			pageNo++;
		}
		loadPage(pageNo);
	});
	pageCounter = $('#pageCounter');
	loadPage(1);
	
});
function loadPage(pageNo){
	$.get("${path}/c/listNews.json?type=${type}&page="+pageNo,function(page){
		pageNo = page.pageNo;
		pageCount = page.totalPage;
		pageCounter.html(pageNo+" / "+pageCount);
		pagePrev[0].setAttribute('data-state', pageNo<=1 ? 'disabled' : '');
		pageNext[0].setAttribute('data-state', pageNo>=pageCount ? 'disabled' : '');
		
		var list = page.rows;
		var newslist = $('#newslist');
		newslist.empty();
		$.each(list, function(i, d){
			var str = '<div class="lleftBox"> <div class="imgBox"> <a href="${path}/c/detail.do?id='+d.articleId+'"> <img src="'+(d.thumb ? imgpath+d.thumb : '')+'" alt="" onerror="this.src=\'${path}/cms/def/news.png\'"/> </a>'
				+' </div> <div class="textBox"> <a href="${path}/c/detail.do?id='+d.articleId+'"> <p>'+d.articleTitle+'</p> </a> <div class="bottomIconText"> '
				+'<div> <img src="${path}/cms/images/time.png" alt=""> </div> <p> '+formatDate(d.createTime, 'yyyy-MM-dd HH:mm')+' </p> </div> </div> </div>';
			newslist.append(str);
		});
	});
	
}

</script>
</body>
</html>